package com.mspbots.core.teams.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mspbots.core.DefaultBaseMapper;
import com.mspbots.core.teams.model.BotMessageCacheDTO;
import com.mspbots.core.teams.model.Messages;
import com.mspbots.core.teams.model.MessagesIncontrollable;
import com.mspbots.cw.request.MessagesDTO;
import com.mspbots.cw.request.TriggerEscalationDTO;
import com.mspbots.dto.statistics.MessagesStatisticDTO;
import com.mspbots.dto.statistics.MessagesStatisticUserDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author billb
 */
@Mapper
public interface MessagesMapper extends DefaultBaseMapper<Messages> {

    /**
     * TODO
     *
     * @param messages
     * @return java.util.List<com.mspbots.core.dto.Messages>
     * @author Jun Zhou
     * @date 14:32 2019/6/25
     **/
    List<Messages> findList(Messages messages);

    /**
     * TODO
     *
     * @param entryId
     * @return
     */
    List<MessagesDTO> findByTimeEntryId(@Param("entryId") Long entryId);

    List<MessagesStatisticDTO> countByType(@Param("tenantId") Long tenantId);

    List<MessagesStatisticDTO> countByDay(MessagesStatisticDTO messagesStatisticDTO);

    List<MessagesDTO> reportPage(Page page, @Param("query") MessagesDTO query);

    int countByGroupUser(Long tenantId);

    TriggerEscalationDTO triggerEscalationList(TriggerEscalationDTO query);

    Page<MessagesStatisticUserDTO> countByDayUser(Page<MessagesStatisticUserDTO> page,
                                                  @Param("messagesStatisticUserDTO") MessagesStatisticUserDTO messagesStatisticUserDTO);

    int countEscalation(Messages query);

    Object insertMessages(Messages entity);

    List<MessagesIncontrollable> incontrollable(MessagesIncontrollable params);

    LocalDateTime maxCreateTime(BotMessageCacheDTO query);

    Long selectMinId(Long tenantId);

    Long selectMaxId(Long tenantId);

    Long deleteByMinMaxId(Long tenantId, Long messagesMinId, Long messagesMaxId);

}
